import React, { Component ,Suspense} from 'react'
import {Switch,Route,Redirect} from "react-router-dom"
export class RouterView extends Component {
    render() {
        let {routes} = this.props
        return (
            <Suspense fallback={"路由跳转中，请您稍等"}>
                <Switch>
                    {
                        routes&&routes.map((item,index)=>{
                            return <Route  key={index} path={item.path} render={(props)=>{
                                return item.redirect?<Redirect to={item.redirect}/>
                                :<item.component {...props} routes={item.children}/>
                            }}></Route>
                        })
                       
                    }
                  
                </Switch>

            </Suspense>
        )
    }
}

export default RouterView
